/*
 * 退货记录表格配置
 * 定义表格列、表单字段、查询条件等
 */
export default function () {
    const table = {
        key: 'id',
        cnName: '退货记录',
        name: 'return_order',
        url: '/api/return_order/',
        sortName: 'create_time'
    };
    
    const tableName = table.name;
    const tableCNName = table.cnName;
    const newTabEdit = false;
    const key = table.key;
    
    const editFormFields = {
        "return_no": "",
        "return_name": "",
        "customer_id": "",
        "create_time": "",
        "total_amount": 0,
        "order_status": 2,
        "shipping_address": ""
    };
    
    const editFormOptions = [
        [
            {"title": "退货编号", "field": "return_no", "type": "text", "disabled": true},
            {"title": "商品名称", "field": "return_name", "type": "text", "disabled": true}
        ],
        [
            {"title": "订单编号", "field": "shipping_address", "type": "text", "disabled": true},
            {"title": "客户ID", "field": "customer_id", "type": "number", "disabled": true}
        ],
        [
            {"title": "创建时间", "field": "create_time", "type": "datetime", "disabled": true},
            {"title": "订单金额", "field": "total_amount", "type": "decimal", "disabled": true}
        ],
        [
            {"title": "状态", "field": "order_status", "type": "select", "disabled": true, "data": [
                { key: 0, value: '待处理' },
                { key: 1, value: '已审核' },
                { key: 2, value: '已完成' },
                { key: 3, value: '已取消' }
            ]}
        ]
    ];
    
    const searchFormFields = {};
    const searchFormOptions = [];
    
    const columns = [
            {
                field: 'id',
                title: 'ID',
                type: 'int',
                width: 80,
                readonly: true,
                hidden: true // 隐藏ID列
            },
            {
                field: 'return_no',
                title: '退货编号',
                type: 'string',
                width: 180,
                readonly: true,
                require: true,
                align: 'left'
            },
            {
                field: 'shipping_address',
                title: '订单编号',
                type: 'string',
                width: 180,
                readonly: true,
                align: 'left'
            },
            {
                field: 'return_name',
                title: '商品名称',
                type: 'string',
                width: 200,
                readonly: true,
                require: true
            },
            {
                field: 'customer_id',
                title: '客户ID',
                type: 'int',
                width: 100,
                readonly: true,
                align: 'center'
            },
            {
                field: 'create_time',
                title: '创建时间',
                type: 'datetime',
                width: 160,
                readonly: true,
                require: true,
                align: 'center'
            },
            {
                field: 'total_amount',
                title: '订单金额',
                type: 'decimal',
                width: 120,
                readonly: true,
                align: 'right',
                formatter: (row, column, cellValue) => {
                    return cellValue ? `¥${cellValue.toFixed(2)}` : '¥0.00';
                }
            },
            {
                field: 'total_amount',
                title: '数量',
                type: 'decimal',
                width: 100,
                readonly: true,
                align: 'center',
                hidden: true // 暂时隐藏，因为没有Num字段
            },
            {
                field: 'order_status',
                title: '状态',
                type: 'sbyte',
                width: 100,
                readonly: true,
                align: 'center',
                formatter: (row, column, cellValue) => {
                    const statusMap = {
                        0: '待处理',
                        1: '已审核',
                        2: '已完成',
                        3: '已取消'
                    };
                    return statusMap[cellValue] || '未知';
                }
            }
        ],
        
        // 明细表配置
        detail: {columns: []},
        details: []
    };
}

